package net.bwie.jtp.app.utf;

import ch.hsr.geohash.GeoHash;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;

@Description(
        name = "convert_geohash",
        value = "_FUNC_(latitude,longitude) - return a geohash code"
)
public  class ConverGeoHash extends UDF {
    public String evaluate(double latitude,double longitude,int percision){
        GeoHash geoHash = GeoHash.withCharacterPrecision(latitude, longitude, percision);
        return geoHash.toBase32();
    }

    public static void main(String[] args) {
        String evaluate = new ConverGeoHash().evaluate(35.46847397820407,119.36278007513695,8);
        System.out.println(evaluate);
    }
}


